package com.example.myapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

public class MainActivity extends AppCompatActivity {
    private Spinner spinner;
    private Object Spinner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String[] activities = {"RobotActivity", "ImageActivity", "VideoActivity", "ShopActivity"};
        spinner = (Spinner) findViewById(R.id.spinner);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                this, android.R.layout.simple_spinner_dropdown_item, activities);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        Button btnStart = (Button) findViewById(R.id.btnStart);
        btnStart.setOnClickListener(view -> {
            String activity = "com.example.myapp." + spinner.getSelectedItem().toString();
            try {
                Intent intent = new Intent(MainActivity.this, Class.forName(activity));
                startActivity(intent);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
                return;
            }
        });
    }
}